#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int main()

{
	int i = 0;
	int n = 0;
	int a = 0;
	int sum = 0;
	scanf("%d", &n);
	int arr[2000] = { 0 };
	for (i = 0; i < n; i++)
	{
		scanf("%d", &a);
		arr[i] = a;
	}
	int j = 0;
	int k = 0;
	scanf("%d", &j);
	for (k = 0; k < j; k++)
	{
		int left = 0;
		int right = 0;
		scanf("%d", &left);
		scanf("%d", &right);
		if (left <= 0)
		{
			left = 1;
		}
		for (i = left - 1; i < right; i++)
		{
			sum = sum + arr[i];
		}
		printf("%d\n", sum);
		sum = 0;
	}
	return 0;
}